var phonecatControllers = angular.module('phonecatControllers', []);

// phonecatControllers.controller('PhoneListCtrl', ['$scope', '$http',
// 	function($scope, $http) {
// 		$http.get('data/phones.json').success(function(data) {
// 			$scope.phones = data;
// 		});

// 		$scope.orderProp = 'age';
// 	}
// ]);

// phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams', '$http',
// 	function($scope, $routeParams, $http) {
// 		$http.get('data/' + $routeParams.phoneId + '.json').success(function(data) {
// 			$scope.phone = data;
// 			$scope.mainImageUrl = data.images[0];
// 		});
// 		$scope.setImage = function(imageUrl) {
// 			$scope.mainImageUrl = imageUrl;
// 		};
// 	}
// ]);

phonecatControllers.controller('PhoneListCtrl', ['$scope', 'Phone',
	function($scope, Phone) {
		$scope.phones = Phone.query();
		$scope.orderProp = 'age';
	}
]);

phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams', 'Phone',
	function($scope, $routeParams, Phone) {
		$scope.phone = Phone.get({
			phoneId: $routeParams.phoneId
		}, function(phone) {
			$scope.mainImageUrl = phone.images[0];
		});
		$scope.setImage = function(imageUrl) {
			$scope.mainImageUrl = imageUrl;
		};
	}
]);